package com.rakuten.api.mule.transformers;

import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.api.transport.PropertyScope;
import org.mule.transformer.AbstractMessageTransformer;

import com.rakuten.api.mule.model.ItemRoot;


public class AppendMerchantIdToProduct extends AbstractMessageTransformer {
		@Override
		public Object transformMessage(MuleMessage message, String outputEncoding)
				throws TransformerException {
			try {
				String merchantId = message.getProperty("merchantId",
						PropertyScope.SESSION);		
				ItemRoot itemRoot = message.getPayload(ItemRoot.class);	
				itemRoot.setMerchantId(merchantId);
				return itemRoot;
			} catch (Exception ex) {
				throw new TransformerException(this, ex);
			}
		}
	
}
